FROM nginx:1.24.0
RUN mkdir /code
WORKDIR /code
COPY . /code
RUN sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list \
    && sed -i 's|security.debian.org/debian-security|mirrors.ustc.edu.cn/debian-security|g' /etc/apt/sources.list \
    && apt update \
    && apt install -y nodejs npm \
    && npm install \
    && npm run build

FROM nginx:1.24.0
WORKDIR /usr/share/nginx/html
RUN rm -rf /usr/share/nginx/html/*
COPY --from=0 /code/dist /usr/share/nginx/html
RUN chmod 777 -R /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
